package com.yonyou.crm.bpub.approval.rmimpl;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yonyou.crm.bpub.approval.entity.ActionVO;
import com.yonyou.crm.bpub.approval.entity.DjInfoVO;
import com.yonyou.crm.bpub.approval.entity.HistoryVO;
import com.yonyou.crm.bpub.approval.entity.ProcessModelVO;
import com.yonyou.crm.bpub.approval.entity.TaskVO;
import com.yonyou.crm.bpub.approval.rmitf.IProcessRmService;
import com.yonyou.crm.bpub.approval.service.ProcessBizServiceImpl;
import com.yonyou.crm.common.page.entity.Page;

@Service
public class ProcessRmServiceImpl implements IProcessRmService {

	@Autowired
	ProcessBizServiceImpl service;
	
	@Override
	public String getTenant() {
		return service.getYsTenantId(null);
	}

	@Override
	public void synDeptsAndUsers() {
		service.synDeptsAndUsers();
	}

	@Override
	public String createProcess(Map<String, Object> paraMap) {
		return service.createProcess(paraMap);
	}
	
	/*
	 * 删除流程定义模型
	 */
	@Override
	public boolean deleteProcessModel(String modelId) {
		return service.deleteProcessModel(modelId);
	}
	
	/*
	 * 返回审批流列表
	 */
	@Override
	public List<ProcessModelVO> getProcessModelList(Map<String, Object> paraMap) {
		return service.getProcessModelList(paraMap);
	}
	
	@Override
	public boolean actionTask(Long businessId, int djType, String instanceId, String taskId, String comment, String action) {
		return service.actionTask(businessId, djType, instanceId, taskId, comment, action);
	}
	
	/*
	 * 提醒审批
	 */
	@Override
	public void remind(Long businessId, int djType, List<String> personlist) {
		service.remind(businessId, djType, personlist);
	}
	
	/*
	 * 获取未完成流程实例列表
	 */
	@Override
	public Page<DjInfoVO> getNotFinished(Map<String, Object> paraMap){
		return service.getProcessInstanceList(false, paraMap);
	}
	
	/*
	 * 获取已完成流程实例列表
	 */
	@Override
	public Page<DjInfoVO> getFinished(Map<String, Object> paraMap) {
		return service.getProcessInstanceList(true, paraMap);
	}
	
	/*
	 * 查询单个流程实例(详情)
	 */
	@Override
	public <T extends Serializable> T getDetail(Long businessId, int djType) {
		return service.getDetail(businessId, djType);
	}
	
	/*
	 * 获取审批动作列表
	 */
	@Override
	public List<ActionVO> getActions(String instanceId, String taskId) {
		return service.getActions(instanceId, taskId);
	}
	
	/*
	 * 获取审批历史
	 */
	@Override
	public List<HistoryVO> getHistoryTasks(Long businessId, int djType, String order) {
		return service.getHistoryTasks(businessId, djType, order);
	}

	/*
	 * 查询待办任务列表
	 */
	public Page<TaskVO> getTasksTodo(Map<String, Object> paraMap){
		return service.getTasksTodo(paraMap);
	}
	
	/*
	 * 查询已办任务列表
	 */
	public Page<TaskVO> getTasksDone(Map<String, Object> paraMap) {
		return service.getTasksDone(paraMap);
	}
	@Override
	public int getProcessInstancesCount(Boolean isFinished) {
		return service.getProcessInstancesCount(isFinished);
	}
	
	@Override
	public int getTasksCount(Boolean isFinished) {
		return service.getTasksCount(isFinished);
	}

	@Override
	public void saveTenant(Long tenantId) {
		service.saveTenant(tenantId);
	}

}
